var webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractCSS = new ExtractTextPlugin('/stylesheets/[name]-one.css');
const extractSass = new ExtractTextPlugin({
    filename: "/stylesheets/[name].[contenthash].css",
    disable: process.env.NODE_ENV === "development"
});
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    // 页面入口文件配置
    entry: {
        index: __dirname + '/src/js/page/index.js',
        v:['jquery']
    },

    //入口文件输出配置
    output: {
        path: __dirname + '/assets',
        filename: 'js/page/[name].min.js'/*,
        publicPath: "/"*/
    },
    module: {
        rules: [{
            test: /\.scss$/,
            use: extractSass.extract({
                use: [{
                    loader: "css-loader"
                }, {
                    loader: "sass-loader"
                }],
                // use style-loader in development 
                fallback: "style-loader"
            })
        }, {
            test: /\.css$/,
            use: extractCSS.extract({
                fallback: "style-loader",
                use: "css-loader"
            })
        }]
    },
    plugins: [
        extractCSS,
        extractSass,
        new HtmlWebpackPlugin({
            title: 'study webpack',
            template:'src/tpl/test.html',
            filename: 'index.html'
        }),
        new webpack.ProvidePlugin({
            $:'jquery'
        }),
        new webpack.optimize.CommonsChunkPlugin({name:"v",filename:'lib/jquery.min.js'})
    ],
    devServer: {
        contentBase: "./",
        host: "10.2.235.36",
        port: "8090"
    }
};